<template>
	<view class="goods">
		<u-navbar title="平台云仓" bgColor="rgba(255,255,255,0.0)" :auto-back="true" :placeholder="true">
		</u-navbar>
		<view class="goods-item" v-for="(item,index) in relist" :key="index" @click="goDetails(item.id)">
			<image :src="item.goodsImgs" mode=""></image>
			<view class="goods-right">
				<view class="goods-title">
					{{item.goodsName}}
				</view>
				<view class="goods-num">
					已售出{{item.quantitySold}}
				</view>
				<view class="goods-price">
					￥<text>{{item.currentPrice}}</text>
				</view>
			</view>
		</view>
		<u-loadmore :status="status" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				relist: [],
				page: 1,
				status: 'loadmore',
			}
		},
		onLoad() {
			this.postrelist()
		},
		onReachBottom() {
			this.page = this.page + 1
			this.status = 'loading';
			this.postrelist()
		},
		methods: {
			postrelist() {
				let params = {
					pageNum: this.page,
					pageSize: 10
				}
				this.$Request({
					method: 'GET',
					url: '/api/goods/info/re-list',
					data: params,
					ismsg: false,
				}).then(res => {
					if (res.code == 200) {
						if (res.rows.length < 10) {
							this.status = 'nomore';
						}
						if (this.page == 1) {
							this.relist = res.rows
						} else {
							this.relist = [...this.relist, ...res.rows]
						}
					}
				})
			},
			goDetails(id) {
				uni.navigateTo({
					url: '/pages/index/details/index?id=' + id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.goods {
		padding: 10rpx 20rpx;
		min-height: calc(100vh - 91rpx);
		background-image: url('../../../static/goods/top-bg.png');
		background-size: 100% 561rpx;
		background-repeat: no-repeat;

		.goods-item {
			display: flex;
			align-items: center;
			margin-top: 30rpx;
			background-color: #fff;
			box-shadow: 0px 0px 30px 1px rgba(0, 0, 0, 0.06);
			padding: 20rpx;
			border-radius: 30rpx;

			image {
				width: 232rpx;
				height: 232rpx;
				border-radius: 30rpx;
			}

			.goods-right {
				margin-left: 20rpx;

				.goods-title {
					color: #333333;
					font-size: 28rpx;
					font-weight: bold;
				}

				.goods-num {
					font-size: 24rpx;
					color: #999999;
					margin-top: 10rpx;
				}

				.goods-price {
					width: 388rpx;
					height: 60rpx;
					background-image: url('../../../static/home/price-bg.png');
					background-repeat: no-repeat;
					background-size: 100% 100%;
					line-height: 60rpx;
					display: flex;
					align-items: center;
					color: #FB510D;
					padding: 0 15rpx;
					margin-top: 50rpx;

					text {
						font-size: 48rpx;
						font-weight: bold;
						margin-left: 10rpx;
					}
				}
			}
		}
	}
</style>